package com.binguo.wxapi.passengerflow;

import com.binguo.wxapi.passengerflow.hkym.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;


@FeignClient(url = "https://api2.hik-cloud.com", name = "ymApiFeign")
public interface YmApiFeign {



    @PostMapping(value = "/oauth/token", produces = APPLICATION_JSON_VALUE)
    TokenResponse getToken(@RequestParam("client_id") String client_id
            , @RequestParam("client_secret") String client_secret
            , @RequestParam("grant_type") String grant_type

    );

    @PostMapping(value = "/v1/groups/add", produces = APPLICATION_JSON_VALUE)
    CommonObj<GroupAdd> addGroup(@RequestHeader("Authorization") String token
            , @RequestParam("groupName") String groupName
            , @RequestParam(value = "parentId", required = false) String parentId

    );


    @PostMapping(value = "/v1/devices/add", produces = APPLICATION_JSON_VALUE)
    CommonObj<DeviceAdd> addDevice(
            @RequestHeader("Authorization") String token,
            @RequestParam("groupId") String groupId
            , @RequestParam("deviceSerial") String deviceSerial
            , @RequestParam("validateCode") String validateCode
    );

    @PostMapping(value = "/v1/devices/{deviceId}/synchChannels", produces = APPLICATION_JSON_VALUE)
    CommonObj synchChannels(
            @RequestHeader("Authorization") String token,
            @RequestParam("deviceId") String deviceId
    );


    @GetMapping(value = "/v1/groups/list", produces = APPLICATION_JSON_VALUE)
    CommonObj<List<GroupAdd>> groupList(
            @RequestHeader("Authorization") String token
    );

    /**
     * 关闭设备视频加密
     * @param token
     * @param deviceId
     * @param validateCode
     * @return
     */
    @PostMapping(value = "/v1/devices/{deviceId}/encrypt/off", produces = APPLICATION_JSON_VALUE)
    CommonObj encryptOff(
            @RequestHeader("Authorization") String token,
            @RequestParam("deviceId") String deviceId,
            @RequestParam("validateCode") String validateCode
    );

    /**
     * 开通标准流预览功能
     * @param token
     * @param channelIds
     * @return
     */
    @PostMapping(value = "/v1/devices/liveVideoOpen", produces = APPLICATION_JSON_VALUE)
    CommonObj liveVideoOpen(
            @RequestHeader("Authorization") String token,
            @RequestParam("channelIds") String channelIds
    );

    /**
     * 获取标准流预览地址
     * @param token
     * @param channelId
     * @return
     */
    @GetMapping(value = "/v1/devices/liveAddress", produces = APPLICATION_JSON_VALUE)
    CommonObj<LiveAddress> liveAddress(
            @RequestHeader("Authorization") String token,
            @RequestParam("channelId") String channelId
    );

    @GetMapping(value = "/v1/devices/{deviceId}/info", produces = APPLICATION_JSON_VALUE)
    CommonObj<DeviceAdd> deviceInfo(
            @RequestHeader("Authorization") String token,
            @RequestParam("deviceId") String deviceId
    );

    @GetMapping(value = "/v1/channels/list", produces = APPLICATION_JSON_VALUE)
    CommonObj<ChannelInfo> channelList(
            @RequestHeader("Authorization") String token
            , @RequestParam("deviceId") String deviceId
            , @RequestParam("pageNo") String pageNo
            , @RequestParam("pageSize") String pageSize
    );


    @GetMapping(value = "/v1/devices/list", produces = APPLICATION_JSON_VALUE)
    String  deviceList(
            @RequestHeader("Authorization") String token
            , @RequestParam("groupId") String groupId
            , @RequestParam("pageNo") String pageNo
            , @RequestParam("pageSize") String pageSize
    );


    /**
     * 查询客流小时数据
     * @param token
     * @param channelId
     * @param date
     * @return
     */
    @GetMapping(value = "/v1/passengerflow/hourly", produces = APPLICATION_JSON_VALUE)
    CommonObj<List<Pflow>> passengerflow(
            @RequestHeader("Authorization") String token
            , @RequestParam("channelId") String channelId
            , @RequestParam("date") String date
    );


    /**
     * consumer
     * @param token
     * @param consumerName
     * @return
     */
    @PostMapping(value = "/api/v1/mq/consumer/group1", produces = APPLICATION_JSON_VALUE)
    CommonObj<ConsumerId> consumer(
            @RequestHeader("Authorization") String token
            , @RequestParam("consumerName") String consumerName
    );


    /**
     * delete
     * @param token
     * @param deviceId
     * @return
     */
    @PostMapping(value = "/v1/devices/{deviceId}/delete", produces = APPLICATION_JSON_VALUE)
    CommonObj delete(
            @RequestHeader("Authorization") String token
            , @RequestParam("deviceId") String deviceId
    );


    /**
     * messages
     * @param token
     * @param consumerId
     * @return
     */
    @PostMapping(value = "/api/v1/mq/consumer/messages", produces = APPLICATION_JSON_VALUE)
    CommonObj<List<ConsumeMsg>> messages(
            @RequestHeader("Authorization") String token
            , @RequestParam("consumerId") String consumerId
            , @RequestParam("autoCommit") Boolean autoCommit
    );


    @GetMapping(value = "/v1/ezviz/account/info")
    CommonObj<AccountInfo> accountInfo(@RequestHeader("Authorization") String token);
}
